#!/usr/bin/python
import sys

import urllib2
import urllib
import mechanize
import re

def send_sms(logins,passs,number,message):
	czas='0'
        sets = {"login":"%s"%logins,"pass":"%s"%passs}


        values = {'login' : sets['login'],
                'haslo' : sets['pass'] }


        br = mechanize.Browser()
        br.open('https://24.playmobile.pl/Play24/')
        br.select_form(nr=0)
        br.submit()

        sms=-1;

        br.select_form(name="loginForm")
        br['login']=sets['login']
        br['password']=sets['pass']
        br.submit()

        cookie=br.response().info()['set-cookie']

        br.select_form(nr=0)
        res=br.submit()


        br.open('https://bramka.playmobile.pl/composer/public/editableSmsCompose.do')
        br.select_form(nr=0)
        br.submit()

        br.select_form(nr=0)
        br.submit()

        br.select_form(nr=0)
        br.submit()
        br.select_form(nr=0)
        br.form.set_all_readonly(False)
        br['recipients']=number
        br['content_out']=message
        br['content_in']='test2'
        br['czas']=['%s'%czas]
        br['sendform']='on'
        br['old_content']='test3'
        br.form.action='https://bramka.playmobile.pl/composer/public/editableSmsCompose.do'
        br.submit()

        br.open('https://bramka.playmobile.pl/composer/public/editableSmsCompose.do?SMS_SEND_CONFIRMED=Wy%9Clij')

        return 1


send_sms(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4]);

